begintownscript;

variables;
short bmessage,pcs,seated,leadchar,rctx,rcty;
string custom_m;

body;

beginstate INIT_STATE;

	rctx = 29;
	while(rctx <= 35){
		rcty = 47;
		while(rcty <= 51){
			move_item_on_spot(rctx,rcty,-1,-1);
			rcty = (rcty + 1);
		}
		rctx = (rctx + 1);
	}
	leadchar = 0;
	while(char_ok(leadchar) == FALSE){
		leadchar = (leadchar + 1);
	}
	relocate_character(leadchar,33,49);
	set_character_facing(leadchar,0);
	force_view_center(33,49);
	force_instant_terrain_redraw();
	pause(8);

	reset_dialog();
	add_dialog_str(0,"IMAGINE!",0);
	add_dialog_str(1,"This is where you and your teddy bear brother drink sweet tea and relax.  It is a happy place for both humans and bears.",0);
	add_dialog_choice(0,". . .");
	bmessage = run_dialog(0);

	pause(3);
	set_terrain(32,48,253);
	move_item_on_spot(37,49,32,49);
	move_item_on_spot(37,50,32,50);
	force_instant_terrain_redraw();
	pause(7);

	reset_dialog();
	add_dialog_str(0,"The tea is delicious.  It is made from rose hips, chamomile and mint.  The only thing that could make it better is a view.",0);
	add_dialog_choice(0,". . .");
	bmessage = run_dialog(0);

	pause(5);
	set_terrain(29,51,60);
	set_terrain(30,51,60);
	set_terrain(31,51,60);
	set_terrain(32,51,60);
	set_terrain(33,51,60);
	set_terrain(34,51,60);
	set_terrain(35,51,60);
	force_instant_terrain_redraw();
	pause(5);

	rctx = 19;
	while(rctx <= 45){
		rcty = 52;
		while(rcty <= 61){
			if(get_floor(rctx,rcty) == 150)
				set_floor(rctx,rcty,(38 + get_ran(1,0,2)));
			if(get_terrain(rctx,rcty) == 467)
				set_terrain(rctx,rcty,(144 + get_ran(1,0,6)));
			if(get_terrain(rctx,rcty) >= 147)
				set_terrain(rctx,rcty,(get_terrain(rctx,rcty) + 4));
			if(get_ran(1,0,8) == 0)
				force_instant_terrain_redraw();

			rcty = (rcty + 1);
		}

		rctx = (rctx + 1);
	}
	force_instant_terrain_redraw();
	pause(2);

	reset_dialog();
	add_dialog_str(0,"This is a beautiful place to be.  Nature is all around you and everything is way more peaceful.  You can escape from the powers that control you here.",0);
	add_dialog_choice(0,"Finally!");
	bmessage = run_dialog(0);

break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;

	leadchar = 0;
	while(char_ok(leadchar) == FALSE){
		leadchar = (leadchar + 1);
	}
	if(get_flag(1,0) == 7){
		pcs = 6;
		while((char_ok(pcs) == FALSE) && (pcs <= 10)){
			pcs = (pcs + 1);
		}
		if(pcs == 11){
			set_terrain(53,41,0);
			set_terrain(53,43,0);
			activate_hidden_group(2);
			put_boom_on_space(53,41,0,0);
			put_boom_on_space(53,43,0,0);
			force_instant_terrain_redraw();
			run_animation_sound(51);
			pause(4);
			reset_dialog();
			add_dialog_str(0,"You live in a Prison and the wardens are everywhere.  We must always try to liberate our trapped brothers and sisters but it is difficult.",0);
			add_dialog_choice(0,". . .");
			bmessage = run_dialog(0);

			seated = 0;
			set_flag(1,0,8);
		}
	}
	if(get_flag(1,0) == 8){
		seated = (seated + 1);
		if(seated >= 4){
			message_dialog("If you survive and thrive, you may one day grow strong.","");
			force_view_center(54,42);
			set_total_visibility(1);
			force_instant_terrain_redraw();
			pause(4);
			move_item_on_spot(56,42,-1,-1);
			activate_hidden_group(5);
			force_instant_terrain_redraw();
			pause(3);

			set_character_pose(11,1);
			set_terrain(55,42,137);
			force_instant_terrain_redraw();
			play_sound(108);
			pause(3);

			set_character_pose(11,0);
			force_instant_terrain_redraw();
			pause(1);

			relocate_character(11,55,42);
			force_instant_terrain_redraw();
			pause(2);

			relocate_character(11,54,43);
			force_instant_terrain_redraw();
			pause(2);

			set_character_pose(11,1);
			force_instant_terrain_redraw();
			play_sound(33);
			pause(1);

			put_effect_on_space(53,43,12,1,2);
			run_animation_sound(118);
			pause(1);

			kill_char(13,2,0);
			pause(1);

			set_character_pose(11,0);
			force_instant_terrain_redraw();
			pause(1);

			erase_char(12);
			activate_hidden_group(3);
			force_instant_terrain_redraw();
			pause(2);

			set_character_pose(15,1);
			put_jagged_zap(53,41,54,43,3);
			set_char_status(11,29,16,1,0);
			force_instant_terrain_redraw();
			run_animation_sound(43);
			pause(4);

			message_dialog("Your brother is now trapped!  Liberate him!  Strike now!","");
			set_total_visibility(0);
			force_view_center(char_loc_x(leadchar),char_loc_y(leadchar));
			force_instant_terrain_redraw();
			pause(3);

			set_flag(1,0,9);
		}
	}
	if(get_flag(1,0) == 10){
		if(is_combat() == FALSE){
			relocate_character(leadchar,53,13);
			force_view_center(53,13);
			force_instant_terrain_redraw();
			pause(5);

			message_dialog("Oppression is a prison, and we must all break loose!  Down with the wardens, down with the prison gates!","");
			pause(6);

			rctx = 49;
			while(rctx <= 57){
				set_terrain(rctx,8,0);
				set_terrain(rctx,18,0);

				rctx = (rctx + 1);
			}
			rcty = 9;
			while(rcty <= 17){
				set_terrain(48,rcty,0);
				set_terrain(58,rcty,0);

				rcty = (rcty + 1);
			}
			rctx = 49;
			while(rctx <= 57){
				set_floor(rctx,9,255);
				set_floor(rctx,17,255);

				rctx = (rctx + 1);
			}
			rcty = 9;
			while(rcty <= 17){
				set_floor(49,rcty,255);
				set_floor(57,rcty,255);

				rcty = (rcty + 1);
			}
			rctx = 50;
			while(rctx <= 56){
				set_terrain(rctx,9,4);
				set_terrain(rctx,17,2);

				rctx = (rctx + 1);
			}
			rcty = 10;
			while(rcty <= 16){
				set_terrain(49,rcty,5);
				set_terrain(57,rcty,3);

				rcty = (rcty + 1);
			}
			force_instant_terrain_redraw();
			play_sound(45);
			pause(6);

			message_dialog("This is the creed of our Nation and the rallying cry of our Revolution!  I am your brother, and I am coming to free you.","");
			pause(6);

			rctx = 50;
			while(rctx <= 56){
				set_terrain(rctx,9,0);
				set_terrain(rctx,17,0);

				rctx = (rctx + 1);
			}
			rcty = 10;
			while(rcty <= 16){
				set_terrain(49,rcty,0);
				set_terrain(57,rcty,0);

				rcty = (rcty + 1);
			}
			rctx = 50;
			while(rctx <= 56){
				set_floor(rctx,10,255);
				set_floor(rctx,16,255);

				rctx = (rctx + 1);
			}
			rcty = 10;
			while(rcty <= 16){
				set_floor(50,rcty,255);
				set_floor(56,rcty,255);

				rcty = (rcty + 1);
			}
			rctx = 51;
			while(rctx <= 55){
				set_terrain(rctx,10,4);
				set_terrain(rctx,16,2);

				rctx = (rctx + 1);
			}
			rcty = 11;
			while(rcty <= 15){
				set_terrain(50,rcty,5);
				set_terrain(56,rcty,3);

				rcty = (rcty + 1);
			}
			force_instant_terrain_redraw();
			play_sound(45);
			pause(6);

			message_dialog("It will be a difficult fight.  We will not win the whole thing in our lifetimes but we must try to take them down wherever we can.","");
			pause(6);

			rctx = 51;
			while(rctx <= 55){
				set_terrain(rctx,10,0);
				set_terrain(rctx,16,0);

				rctx = (rctx + 1);
			}
			rcty = 11;
			while(rcty <= 15){
				set_terrain(50,rcty,0);
				set_terrain(56,rcty,0);

				rcty = (rcty + 1);
			}
			rctx = 51;
			while(rctx <= 55){
				set_floor(rctx,11,255);
				set_floor(rctx,15,255);

				rctx = (rctx + 1);
			}
			rcty = 11;
			while(rcty <= 15){
				set_floor(51,rcty,255);
				set_floor(55,rcty,255);

				rcty = (rcty + 1);
			}
			rctx = 52;
			while(rctx <= 54){
				set_terrain(rctx,11,4);
				set_terrain(rctx,15,2);

				rctx = (rctx + 1);
			}
			rcty = 12;
			while(rcty <= 14){
				set_terrain(51,rcty,5);
				set_terrain(55,rcty,3);

				rcty = (rcty + 1);
			}
			force_instant_terrain_redraw();
			play_sound(45);
			pause(6);

			message_dialog("We're coming for you!  Hold out just a little while longer.  We'll save you soon, I promise.","");
			pause(6);

			rctx = 52;
			while(rctx <= 54){
				set_terrain(rctx,11,0);
				set_terrain(rctx,15,0);

				rctx = (rctx + 1);
			}
			rcty = 12;
			while(rcty <= 14){
				set_terrain(51,rcty,0);
				set_terrain(55,rcty,0);

				rcty = (rcty + 1);
			}
			rctx = 52;
			while(rctx <= 54){
				set_floor(rctx,12,255);
				set_floor(rctx,14,255);

				rctx = (rctx + 1);
			}
			rcty = 12;
			while(rcty <= 14){
				set_floor(52,rcty,255);
				set_floor(54,rcty,255);

				rcty = (rcty + 1);
			}
			set_terrain(53,12,4);
			set_terrain(53,14,2);
			set_terrain(52,13,5);
			set_terrain(54,13,3);

			force_instant_terrain_redraw();
			play_sound(45);
			pause(6);

			message_dialog("But for now, you only freedom...","");

			relocate_character(leadchar,13,13);
			force_view_center(13,12);
			force_instant_terrain_redraw();
			play_sound(45);
			set_name(leadchar,"Hopes and Dreams");
			force_instant_terrain_redraw();
			kill_char(leadchar,2,0);
			force_instant_terrain_redraw();
			pause(12);

			message_dialog("...is in your imagination.","");
			end_scenario(2);
		}
	}

	if(char_ok(11))
		set_char_status(11,29,8,1,0);

break;

beginstate 10;

	if(get_flag(1,0) < 4){
		relocate_character(16,30,48);
		force_instant_terrain_redraw();
		pause(4);

		relocate_character(16,30,47);
		force_instant_terrain_redraw();
		pause(4);

		relocate_character(16,30,46);
		force_instant_terrain_redraw();
		pause(4);

		relocate_character(16,35,42);
		message_dialog("Your teddy bear brother is going into your bedroom for a quick nap.","");
		set_flag(1,0,4);
	}

break;

beginstate 11;

	if(get_flag(1,0) < 5){
		march_party(30,46);
		force_view_center(30,46);
		force_instant_terrain_redraw();
		pause(4);

		message_dialog("This is your bedroom.  It has a statue.","");
		pause(2);
		set_terrain(36,45,242);
		force_instant_terrain_redraw();
		pause(4);

		message_dialog("Of...  a deer.","");
		pause(2);
		set_terrain(36,45,246);
		force_instant_terrain_redraw();
		pause(4);

		message_dialog("And a flowerbed.","");
		pause(2);
		set_terrain(34,45,362);
		force_instant_terrain_redraw();
		pause(4);

		message_dialog("There's a giant tree in the room, too.","");
		pause(2);
		set_floor(32,43,142);
		force_instant_terrain_redraw();
		pause(2);
		set_floor(32,42,142);
		set_floor(31,43,142);
		set_floor(32,43,38);
		set_floor(33,43,142);
		set_floor(32,44,142);
		set_terrain(31,42,164);
		set_terrain(33,42,163);
		set_terrain(31,44,161);
		set_terrain(33,44,162);
		force_instant_terrain_redraw();
		pause(2);
		set_terrain(32,43,154);
		force_instant_terrain_redraw();
		pause(2);
		set_terrain(32,43,153);
		force_instant_terrain_redraw();
		pause(2);
		set_terrain(32,43,152);
		force_instant_terrain_redraw();
		pause(4);

		message_dialog("We pick apples from it.","");
		pause(2);
		move_item_on_spot(27,44,31,44);
		force_instant_terrain_redraw();
		pause(4);

		message_dialog("And books that we can read together.","");
		pause(2);
		set_terrain(29,46,235);
		force_instant_terrain_redraw();
		pause(1);
		set_terrain(29,45,235);
		force_instant_terrain_redraw();
		pause(1);
		set_terrain(29,44,235);
		force_instant_terrain_redraw();
		pause(1);
		set_terrain(29,43,235);
		force_instant_terrain_redraw();
		pause(1);
		set_terrain(29,42,235);
		force_instant_terrain_redraw();
		pause(2);

		set_flag(1,0,5);
		block_entry(1);
	}

break;

beginstate 12;

	if(get_flag(1,0) < 6){
		activate_hidden_group(4);
		put_boom_on_space(35,41,2,0);
		force_instant_terrain_redraw();
		run_animation_sound(10);
		pause(3);

		set_character_pose(14,1);
		force_instant_terrain_redraw();
		pause(3);

		put_boom_on_space(35,42,2,0);
		erase_char(16);
		force_instant_terrain_redraw();
		run_animation_sound(10);
		pause(3);

		set_character_pose(14,0);
		force_instant_terrain_redraw();
		pause(1);

		set_character_pose(14,1);
		force_instant_terrain_redraw();
		pause(2);

		set_terrain(37,42,270);
		set_terrain(37,43,270);
		set_terrain(37,44,270);
		put_boom_on_space(37,42,0,0);
		put_boom_on_space(37,43,0,0);
		put_boom_on_space(37,44,0,0);
		force_instant_terrain_redraw();
		run_animation_sound(51);
		pause(3);

		set_character_pose(14,0);
		force_instant_terrain_redraw();
		pause(1);

		relocate_character(14,36,42);
		set_character_facing(14,6);
		force_instant_terrain_redraw();
		pause(2);

		relocate_character(14,37,43);
		force_instant_terrain_redraw();
		pause(2);

		erase_char(14);
		put_boom_on_space(37,43,2,0);
		force_instant_terrain_redraw();
		run_animation_sound(10);
		pause(3);

		message_dialog("Those bastards stole your brother away.  You must steal him back to safety.  After him!","");
		set_flag(1,0,6);
		block_entry(1);
	}

break;

beginstate 13;

	leadchar = 0;
	while(char_ok(leadchar) == FALSE){
		leadchar = (leadchar + 1);
	}
	if((char_loc_y(leadchar) >= 42) && (char_loc_y(leadchar) <= 44)){
		march_party(37,43);
		force_view_center(37,43);
	}
	if(char_loc_y(leadchar) == 41){
		march_party(37,42);
		force_view_center(37,42);
	}
	if(char_loc_y(leadchar) == 45){
		march_party(37,44);
		force_view_center(37,44);
	}
	force_instant_terrain_redraw();
	pause(4);

	set_terrain(38,42,0);
	set_terrain(38,43,0);
	set_terrain(38,44,0);
	march_party(38,43);
	force_view_center(38,43);
	force_instant_terrain_redraw();
	pause(4);

	march_party(39,43);
	force_view_center(39,43);
	force_instant_terrain_redraw();
	pause(4);

	set_terrain(38,42,3);
	set_terrain(38,43,3);
	set_terrain(38,44,3);
	put_boom_on_space(38,42,0,0);
	put_boom_on_space(38,43,0,0);
	put_boom_on_space(38,44,0,0);
	force_instant_terrain_redraw();
	run_animation_sound(51);
	pause(4);

	block_entry(1);

break;

beginstate 14;

	if(get_flag(1,0) < 7){
		reset_dialog();
		add_dialog_str(0,"The world will always try to distract you with things that aren't really important.  You will not know anything about what is around you and it will be scary.",0);
		add_dialog_str(1,"You must FIGHT the POWER!",0);
		add_dialog_choice(0,"!");
		bmessage = run_dialog(0);

		activate_hidden_group(1);
		put_boom_on_space(48,38,2,0);
		put_boom_on_space(45,40,2,0);
		put_boom_on_space(40,43,2,0);
		put_boom_on_space(41,46,2,0);
		put_boom_on_space(48,47,2,0);
		set_name(6,"School");
		set_name(7,"Bullies");
		set_name(8,"Teachers");
		set_name(9,"Religion");
		set_name(10,"Manners");
		force_instant_terrain_redraw();
		run_animation_sound(10);
		pause(3);

		block_entry(1);
		set_flag(1,0,7);
	}

break;

